/****************************************************
    文件：AudioSvc.cs
	作者：kk
    邮箱: 627515104@qq.com
    日期：2020/8/26 16:18:1
	功能：Nothing
*****************************************************/

using UnityEngine;

public class AudioSvc : MonoBehaviour
{
    public static AudioSvc Instance = null;

    public AudioSource bgAudio;
    public AudioSource uiAudio;

    public void InitSvc()
    {
        Instance = this;
    }

    public void PlayBGMusic(string name, bool isLoop = true)
    {
        AudioClip audio = ResSvc.Instance.LoadAudio("ResAudio/" + name, true);

        if (bgAudio.clip == null || bgAudio.clip.name != audio.name)
        {
            bgAudio.clip = audio;
            bgAudio.loop = isLoop;
            bgAudio.Play();
        }
    }


    public void PlayUIAudio(string name)
    {
        AudioClip audio = ResSvc.Instance.LoadAudio("ResAudio/" + name,true);
        uiAudio.clip = audio;
        uiAudio.Play();
    }
}